cmake_minimum_required(VERSION 3.8)
project(ltme_node)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
# ---------------------------------------------------------<
set(LDCP_SDK_DIR "lib/ldcp_sdk")
add_subdirectory(${LDCP_SDK_DIR})


find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(ubt_interface REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(OpenSSL REQUIRED)


# 第一个执行程序
add_executable(ltme_node
  "src/ltme_node.cpp"
)

target_include_directories(ltme_node PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
    ${LDCP_SDK_DIR}/include
)

target_link_libraries(ltme_node
  ldcp_sdk
)
ament_target_dependencies(ltme_node
  rclcpp
  std_msgs
  ubt_interface
  nav_msgs
  std_srvs
)

# 第二个执行程序
add_executable(ping_node
	"src/ping_node.cpp"
)

target_include_directories(ping_node PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
    ${LDCP_SDK_DIR}/include
)
ament_target_dependencies(ping_node 
  rclcpp
  std_msgs
  ubt_interface
  nav_msgs
  std_srvs
)

# 第三个执行程序

add_executable(update_firmware
  "src/update_firmware.cpp"
)

target_include_directories(update_firmware PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
    ${LDCP_SDK_DIR}/include
)
target_link_libraries(update_firmware
  ldcp_sdk
  OpenSSL::Crypto
)
ament_target_dependencies(update_firmware 
  rclcpp
  std_msgs
  ubt_interface
  nav_msgs
  std_srvs
)



install(TARGETS 
    ltme_node update_firmware ping_node
    RUNTIME DESTINATION lib/${PROJECT_NAME}
    LIBRARY DESTINATION lib/${PROJECT_NAME}
    ARCHIVE DESTINATION lib/${PROJECT_NAME}
)
# --------------------------------------------------------->

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
